/*
** list_sorted_merge.c for liblist in /home/guina_b/
** 
** Made by benoit guina
** Login   <guina_b@epitech.net>
** 
** Started on  Fri Jan 01 00:00:00 2010 benoit guina
** Last update Fri Jan 01 00:00:00 2010 benoit guina
*/

#include "list.h"

void	*list_sorted_merge(void *a, void *b, int (*c)(void *, void *))
{
  void	*r;
  void	**cur;
  void	**add;

  r = 0;
  cur = &r;
  while (a && b)
    {
      add = (c(a, b) > 0) ? &b : &a;
      *cur = *add;
      *add = *(void **)(*add);
      cur = (void **)(*cur);
    }
  *cur = (a) ? a : b;
  return (r);
}

